package com.xin.di.uav.applet.controller;

import com.xin.di.uav.applet.request.AddSpecificationRequest;
import com.xin.di.uav.applet.resp.SpecificationResponse;
import com.xin.di.uav.applet.service.SpecificationService;
import com.xin.di.uav.common.utils.Rs;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author ltq
 */
@RestController
@RequestMapping("/sys/specifications/")
public class SpecificationController {


    @Autowired
    private SpecificationService specificationService;

    @GetMapping("get-list")
    @Operation(tags = "获取规格列表", description = "获取规格列表")
    public Rs<SpecificationResponse> getList(@RequestParam Integer page, @RequestParam Integer size, @RequestParam String productId) {
        return Rs.success(specificationService.getList(page, size, productId));
    }


    @PostMapping("save")
    @Operation(tags = "保存规格", description = "保存规格")
    public Rs<SpecificationResponse> save(@RequestBody @Valid AddSpecificationRequest addSpecificationRequest) {
        specificationService.save(addSpecificationRequest);
        return Rs.success();
    }
}
